package com.gxpt.app.adapter;

import android.content.Context;
import android.widget.ImageView;
import android.widget.TextView;

import com.gxpt.app.AppUtils;
import com.gxpt.app.Constant;
import com.gxpt.app.R;
import com.gxpt.app.base.ListBaseAdapter;
import com.gxpt.app.base.SuperViewHolder;
import com.gxpt.app.bean.fnewlist_bean;
import com.gxpt.app.bean.newlist_bean;
import com.utils.ScreenUtils;
import com.utils.logger.Logger;
import com.utils.picasso.PicassoUtils;

/**
 * Created by Lzx on 2016/12/30.
 */

public class newlist_Adapter extends ListBaseAdapter<newlist_bean.newlist> {

    //列表图片
    int pic_view_width = 0;
    int pic_view_hight = 0;
    Context context;
    public newlist_Adapter(Context context) {
        super(context);
        this.context = context;
        int Sviewwidth  = ScreenUtils.getScreenWidth(context);//
        pic_view_width  = (Sviewwidth-AppUtils.dip2px(context,10*2))/3;
        pic_view_hight  = pic_view_width/4*3;

//        Logger.i("屏幕 = " + Sviewwidth);
//        Logger.i("宽 = " + pic_view_width);
//        Logger.i("高 = " + pic_view_hight);
    }

    @Override
    public int getLayoutId() {
        return R.layout.item_home_life_list;
    }

    @Override
    public void onBindItemHolder(SuperViewHolder holder, int position) {
        newlist_bean.newlist item = mDataList.get(position);

        TextView list_title = holder.getView(R.id.list_title);
        list_title.setText(item.title);

        TextView list_address = holder.getView(R.id.list_address);
        list_address.setText("");


        TextView list_city_name = holder.getView(R.id.list_city_name);
        list_city_name.setText(item.province_name+item.city_name);

        TextView list_project_amount = holder.getView(R.id.list_project_amount);
        list_project_amount.setText(item.project_amount);
        list_project_amount.append(context.getString(R.string.txt_yuan));

        ImageView pic_url= holder.getView(R.id.list_pic);
        if(item.file_url.isEmpty()){
            PicassoUtils.Picasso_displayImage(context,R.mipmap.ic_launcher,pic_view_width,pic_view_hight,pic_url);
        }else{
            if(AppUtils.isHaveHTTP(item.file_url)){
                PicassoUtils.Picasso_displayImage(context,item.file_url,pic_view_width,pic_view_hight,pic_url);
            }else{
                PicassoUtils.Picasso_displayImage(context,Constant.IP+"/"+item.file_url,pic_view_width,pic_view_hight,pic_url);
            }

        }
    }
}
